// 用express 替代 webpack-dev-server

const express = require("express");

const webpack = require("webpack");

const webpackMiddleware = require("webpack-dev-middleware");
const config = require("./webpack.config");

// js 代码中  打包代码,效果同命令行 npx webpack index.js --config webpack.config.js
const complier = webpack(config);

const app = express();
console.log("========================");
// console.log(complier);
console.log("========================");
app.use(
  webpackMiddleware(complier, {
    publicPath: "/",
  })
);

app.listen(3000, () => {
  console.log("server is runing");
});
